//***************************************************************************
//*
//*	File:			StringEx.h
//*	Description:	Adds some methods to CString
//*
//***************************************************************************
//*
//*	Note:			This source code is provided "as is" meaning that you may 
//*					use it at your own risk. 
//*					You are free to use it in any way you like.
//*
//***************************************************************************
//*
//*	History:		
//*
//*	-------------------------------------------------------------------------
//*	2003/07/27	|	Initial release									|	rk
//*	-------------------------------------------------------------------------
//*
//***************************************************************************

//
//-------------------------------------------------------------- PREPROCESSOR 
//

#ifndef			_STRINGEX_H_INCLUDED
#define			_STRINGEX_H_INCLUDED

#if				_MSC_VER > 1000
#pragma once
#ifdef			__SWITCH_SHOW_HEADER
#pragma message ("-- StringEx.h\n")
#endif
#ifdef			__SWITCH_SHOW_HEADER_TREE
#pragma message ("-- "__FILE__"\n")
#endif
#endif 

//
//-------------------------------------------------------------- DEPENDENCIES
//

//
//--------------------------------------------------------- CLASS DECLARATION
//

//***************************************************************************
//**	@DOC		CLASS CStringEx
//***************************************************************************
//*		@CLASS		Adds some methods to CString
//***************************************************************************
class CStringEx : public CString  
{
	//																										
	//-----------------------------------------------------------------------								
	//****************************     ENUMS     ****************************
	//-----------------------------------------------------------------------								
	//																										
public:																							// @ACCESS	Public Enumerations
	enum EMatchFlag																				// @CMEMBER	Replace flags
	{																							//
		EMatchFlag_Word			= 1 << 0														// @CMEMBER	Match whole words only
	,	EMatchFlag_Case			= 1 << 1														// @CMEMBER	Match case
	,	EMatchFlag_RegExpr		= 1 << 2														// @CMEMBER	Search string is a regular expression 
	,	EMatchFlag_AllCases		= 1 << 3														// @CMEMBER	Match all cases
	};

	//																										
	//-----------------------------------------------------------------------								
	//****************************     FIND     *****************************
	//-----------------------------------------------------------------------								
	//																										
public:																							// @ACCESS	Public Search and Replace Methods
			int		FindNoCase		( const CString&	a_strText
									,		int			a_iStart		= 0		)	const	;	// @CMEMBER	Finds the specified text while ignoring case
			int		FindAllCases	( const CString&	a_strText
									,		int			a_iStart		= 0		
									,		BOOL*		a_pbIsUpper		= NULL		
									,		BOOL*		a_pbIsLower		= NULL	)	const	;	// @CMEMBER	Finds the specified text or it's upper or lower case representation
			int		ReplaceNoCase	( const CString&	a_strFind
									, const CString&	a_strReplace			)			;	// @CMEMBER	Replaces all instances of the find string with the replace string while ignoring the case of the find string
			int		ReplaceAllCases	( const CString&	a_strFind
									, const CString&	a_strReplace			)			;	// @CMEMBER	Replaces all instances of the find string with the replace string for each case (as-is, lower and upper)
					
public:																							// @ACCESS	Public Extended Search and Replace Methods
			BOOL	Matches			( const CString&	a_strFind		
									,		DWORD		a_dwFlags				)	const	;	// @CMEMBER	Determines whether the string matches the specified search string
			int		FindEx			( const CString&	a_strFind				
									,		DWORD		a_dwFlags				)	const	;	// @CMEMBER	Finds the specfied text
			int		ReplaceEx		( const CString&	a_strFind				
									, const CString&	a_strReplace					
									,		DWORD		a_dwFlags				)			;	// @CMEMBER	Replaces all instances of the find string with the replace string 

	//																								
	//-----------------------------------------------------------------------						
	//***********************     CON/DESTRUCTION     ***********************						
	//-----------------------------------------------------------------------						
	//																								
public:																							// @ACCESS	Public Con-/Destruction Methods	
			 CStringEx( const	CStringEx&	a_strText )										;	// @CMEMBER	Copy		constructor
			 CStringEx( const	CString&	a_strText )										;	// @CMEMBER	Assignment	constructor
			 CStringEx( const	UCHAR		a_pchText )										;	// @CMEMBER	Assignment	constructor
			 CStringEx(			LPCTSTR		a_pchText )										;	// @CMEMBER	Assignment	constructor
			 CStringEx(			LPCWSTR		a_pchText )										;	// @CMEMBER	Assignment	constructor
			 CStringEx(			LPCTSTR		a_pchText	, int a_iLength 	)				;	// @CMEMBER	Assignment	constructor
			 CStringEx(			TCHAR		a_chChar	, int a_iRepeat = 1	)				;	// @CMEMBER	Assignment	constructor
			 CStringEx();																		// @CMEMBER	Default		constructor
};
//***************************************************************************
//**	@END
//***************************************************************************

#endif // _STRINGEX_H_INCLUDED
